Skip to content

Conversation

@kirill-vlasov
Copy link
Contributor

This pull request is focused on resolving occurrences of Sonar rule squid:S1155 - Collection.isEmpty() should be used to test for emptiness.
Using Collection.size() to test for emptiness works, but using Collection.isEmpty() makes the code more readable and can be more performant. The time complexity of any isEmpty() method implementation should be O(1) whereas some implementations of size() can be O(n).

You can find more information about the issue here: https://dev.eclipse.org/sonar/coding_rules#q=squid%3AS1155

Please let me know if you have any questions.

Kirill Vlasov

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 16, 2015
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't compile as there's no isFalse method on org.springframework.util.Assert.

@philwebb philwebb removed the status: waiting-for-triage An issue we've not yet triaged label Dec 16, 2015
@philwebb philwebb added this to the 1.3.1 milestone Dec 16, 2015
@philwebb philwebb self-assigned this Dec 16, 2015
@philwebb philwebb closed this in 786aacf Dec 16, 2015
philwebb added a commit that referenced this pull request Dec 16, 2015
* pr/4783:
  Use Collections.isEmpty() instead of .size() == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants